Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Azure Search] Generate code for the Search and ContinueSearch API #5324

Merged
merged 17 commits into from
Mar 8, 2019

Conversation

brjohnstmsft
Copy link
Member

Corresponding Swagger PR: Azure/azure-rest-api-specs#5315 (comment)

This change replaces a bunch of custom code with generated code, specifically for the Search API, and its companion paging method, ContinueSearch.

There are some breaking changes:

  1. DocumentSearchResult/Base and SearchResult/Base have been removed. For dynamic typing scenarios, use DocumentSearchResult<Document> and SearchResult<Document>.
  2. AutocompleteItem properties are now read-only.
  3. The FacetResults and HitHighlights classes have been removed. Facet results are now typed as IDictionary<string, IList<FacetResult>> and hit highlights as IDictionary<string, IList<string>>.
  4. The properties of SearchResult, FacetResult, and DocumentSearchResult are now immutable. If you need to create custom instances of these classes for testing, you can use the new parameterized constructors.
  5. The AutocompleteMode property of AutocompleteParameters is no longer nullable.

We have already bumped the major SDK version in anticipation of these breaking changes.

Big thanks to @mhko who did the exploratory work for generating the Search and ContinueSearch APIs.

FYI @arv100kri @Yahnoosh @natinimni @updixit @ishansrivastava90 @ruiqiding

From now on, for dynamically-typed scenarios, callers of Search need to use
DocumentSearchResult<Document> and SearchResult<Document> instead. This will
make it easier to transition the implementation of this API to generated
code.
This is a breaking change to facilitate more generated code in the SDK. Facet
results are now typed as IDictionary<string, IList<FacetResult>> and hit
highlights as IDictionary<string, IList<string>>.
…Token

Added remarks to the comments for SearchContinuationToken that call out its
ability to be serialized to and from JSON.
This change introduces new generated code and replaces most custom model
class code with generated models, but it does not yet switch over the
implementation of Search to use the new generated code.
This is a temporary step on the way to replacing the custom implementation of
Search with generated code. This change streamlines the process of
deserializing search results by:
  - Removing the unnecessary intermediate DocumentSearchResponsePayload class
  - Moving the logic to build SearchContinuationTokens into
    DocumentSearchResult
  - Passing JsonSerializerSettings to the core operation methods instead of
    passing lambdas

Since DocumentSearchResponsePayload is gone, I also took the opportunity to
make SearchContinuationTokenPayload a private nested class of
SearchContinuationTokenConverter.
Also remove functionality from SearchParameters that isn't used anymore.
Also fixing some Java-isms in a test.
This required some very hacky regexes to customize the generated code, but it
works. Also, it's better than having to parse URL query strings to
reconstitute a SearchParameters instance, since that would miss custom
parameters that can't be modeled in Swagger, like personalization IDs for
custom ranking.

Ideally we'll find a pattern common to other data plane APIs so we don't have
to hack this with regexes for every target language, but it's good enough for
now.
…on-null

Also renamed some properties for consistency.
@UD1412
Copy link

UD1412 commented Mar 8, 2019

sign-off

@brjohnstmsft brjohnstmsft changed the title [DO NOT MERGE] [Azure Search] Generate code for the Search and ContinueSearch A [Azure Search] Generate code for the Search and ContinueSearch API Mar 8, 2019
@brjohnstmsft brjohnstmsft merged commit 6848661 into Azure:search-preview Mar 8, 2019
@brjohnstmsft brjohnstmsft deleted the generate-search branch March 8, 2019 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants